<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI智能推荐 - 外卖平台</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 25px 50px rgba(0,0,0,0.15);
        }
        
        .header {
            text-align: center;
            margin-bottom: 40px;
        }
        
        .header h1 {
            font-size: 2.5rem;
            color: #333;
            margin-bottom: 10px;
        }
        
        .header p {
            color: #666;
            font-size: 1.1rem;
        }
        
        .ai-features {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
            gap: 30px;
            margin-bottom: 40px;
        }
        
        .feature-card {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .feature-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.15);
        }
        
        .feature-icon {
            font-size: 3rem;
            margin-bottom: 20px;
            text-align: center;
        }
        
        .feature-title {
            font-size: 1.5rem;
            color: #333;
            margin-bottom: 15px;
            text-align: center;
        }
        
        .feature-description {
            color: #666;
            line-height: 1.6;
            margin-bottom: 20px;
        }
        
        .feature-demo {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 20px;
            margin-bottom: 20px;
        }
        
        .btn {
            width: 100%;
            padding: 15px;
            background: linear-gradient(135deg, #ff6b6b, #ee5a24);
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
        }
        
        .ai-analysis {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            margin-bottom: 30px;
        }
        
        .analysis-title {
            font-size: 1.8rem;
            color: #333;
            margin-bottom: 20px;
            text-align: center;
        }
        
        .analysis-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }
        
        .analysis-item {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 20px;
            text-align: center;
        }
        
        .analysis-value {
            font-size: 2rem;
            font-weight: bold;
            color: #ff6b6b;
            margin-bottom: 10px;
        }
        
        .analysis-label {
            color: #666;
            font-size: 0.9rem;
        }
        
        .recommendation-list {
            background: white;
            border-radius: 15px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .recommendation-item {
            display: flex;
            align-items: center;
            padding: 20px;
            border: 1px solid #eee;
            border-radius: 10px;
            margin-bottom: 15px;
            transition: all 0.3s ease;
        }
        
        .recommendation-item:hover {
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            transform: translateX(5px);
        }
        
        .recommendation-icon {
            font-size: 2rem;
            margin-right: 20px;
        }
        
        .recommendation-content {
            flex: 1;
        }
        
        .recommendation-title {
            font-size: 1.2rem;
            color: #333;
            margin-bottom: 5px;
        }
        
        .recommendation-description {
            color: #666;
            font-size: 0.9rem;
        }
        
        .confidence-score {
            background: linear-gradient(135deg, #28a745, #20c997);
            color: white;
            padding: 5px 15px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: bold;
        }
        
        .back-btn {
            position: fixed;
            top: 20px;
            left: 20px;
            background: rgba(255, 107, 107, 0.8);
            border: none;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            cursor: pointer;
            color: white;
            font-size: 20px;
            transition: all 0.3s ease;
            z-index: 1000;
        }
        
        .back-btn:hover {
            background: #ff6b6b;
            transform: scale(1.1);
        }
        
        .loading {
            display: none;
            text-align: center;
            padding: 20px;
        }
        
        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #ff6b6b;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
    </style>
</head>
<body>
    <button class="back-btn" onclick="goBack()">←</button>
    
    <div class="container">
        <div class="header">
            <h1>🤖 AI智能推荐系统</h1>
            <p>基于机器学习的个性化推荐，提升用户体验和商家收益</p>
        </div>
        
        <div class="ai-features">
            <div class="feature-card">
                <div class="feature-icon">🎯</div>
                <h3 class="feature-title">智能菜品推荐</h3>
                <p class="feature-description">
                    基于用户历史订单、口味偏好、时间、天气等因素，为用户推荐最合适的菜品。
                </p>
                <div class="feature-demo">
                    <p><strong>推荐逻辑：</strong></p>
                    <p>• 用户历史偏好分析</p>
                    <p>• 实时天气因素</p>
                    <p>• 时段推荐算法</p>
                    <p>• 协同过滤推荐</p>
                </div>
                <button class="btn" onclick="generateDishRecommendations()">生成菜品推荐</button>
            </div>
            
            <div class="feature-card">
                <div class="feature-icon">💰</div>
                <h3 class="feature-title">动态定价优化</h3>
                <p class="feature-description">
                    根据需求预测、库存情况、竞争对手价格等因素，智能调整菜品价格。
                </p>
                <div class="feature-demo">
                    <p><strong>定价策略：</strong></p>
                    <p>• 需求预测模型</p>
                    <p>• 库存优化算法</p>
                    <p>• 竞品价格分析</p>
                    <p>• 收益最大化</p>
                </div>
                <button class="btn" onclick="optimizePricing()">优化定价策略</button>
            </div>
            
            <div class="feature-card">
                <div class="feature-icon">📊</div>
                <h3 class="feature-title">需求预测分析</h3>
                <p class="feature-description">
                    预测未来订单量、热门菜品、配送需求，帮助商家提前准备。
                </p>
                <div class="feature-demo">
                    <p><strong>预测维度：</strong></p>
                    <p>• 订单量预测</p>
                    <p>• 热门菜品分析</p>
                    <p>• 配送需求预测</p>
                    <p>• 季节性趋势</p>
                </div>
                <button class="btn" onclick="predictDemand()">预测需求趋势</button>
            </div>
            
            <div class="feature-card">
                <div class="feature-icon">🚀</div>
                <h3 class="feature-title">配送路线优化</h3>
                <p class="feature-description">
                    基于实时交通、订单分布、骑手位置，智能规划最优配送路线。
                </p>
                <div class="feature-demo">
                    <p><strong>优化算法：</strong></p>
                    <p>• 实时交通数据</p>
                    <p>• 订单聚类分析</p>
                    <p>• 路径规划算法</p>
                    <p>• 时间成本优化</p>
                </div>
                <button class="btn" onclick="optimizeRoutes()">优化配送路线</button>
            </div>
        </div>
        
        <div class="ai-analysis" id="aiAnalysis" style="display: none;">
            <h2 class="analysis-title">AI分析结果</h2>
            <div class="analysis-grid" id="analysisGrid">
                <!-- 分析结果将通过JavaScript动态加载 -->
            </div>
        </div>
        
        <div class="loading" id="loading">
            <div class="spinner"></div>
            <p>AI正在分析中，请稍候...</p>
        </div>
        
        <div class="recommendation-list" id="recommendationList" style="display: none;">
            <h2 style="text-align: center; margin-bottom: 30px; color: #333;">智能推荐结果</h2>
            <div id="recommendations">
                <!-- 推荐结果将通过JavaScript动态加载 -->
            </div>
        </div>
    </div>

    <script src="database.js"></script>
    <script>
        function goBack() {
            window.location.href = 'home.html';
        }
        
        function showLoading() {
            document.getElementById('loading').style.display = 'block';
            document.getElementById('aiAnalysis').style.display = 'none';
            document.getElementById('recommendationList').style.display = 'none';
        }
        
        function hideLoading() {
            document.getElementById('loading').style.display = 'none';
        }
        
        function generateDishRecommendations() {
            showLoading();
            
            setTimeout(() => {
                hideLoading();
                showRecommendations([
                    {
                        icon: '🍜',
                        title: '宫保鸡丁',
                        description: '基于您的历史订单，您经常在午餐时间点川菜，推荐这道经典菜品',
                        confidence: '95%'
                    },
                    {
                        icon: '🥟',
                        title: '水饺套餐',
                        description: '天气较冷，推荐热腾腾的水饺，符合您的口味偏好',
                        confidence: '88%'
                    },
                    {
                        icon: '🍲',
                        title: '酸辣汤',
                        description: '开胃暖身，适合当前季节，预计您会喜欢',
                        confidence: '82%'
                    },
                    {
                        icon: '🍚',
                        title: '蛋炒饭',
                        description: '简单美味，您之前点过3次，推荐再次尝试',
                        confidence: '78%'
                    }
                ]);
            }, 2000);
        }
        
        function optimizePricing() {
            showLoading();
            
            setTimeout(() => {
                hideLoading();
                showAnalysis([
                    { value: '+12%', label: '预期收益提升' },
                    { value: '¥28', label: '宫保鸡丁建议价格' },
                    { value: '¥22', label: '麻婆豆腐建议价格' },
                    { value: '¥35', label: '回锅肉建议价格' }
                ]);
                
                showRecommendations([
                    {
                        icon: '💰',
                        title: '动态定价策略',
                        description: '建议在高峰时段（12:00-13:00）提高热门菜品价格5-10%',
                        confidence: '92%'
                    },
                    {
                        icon: '📈',
                        title: '促销活动建议',
                        description: '针对库存较多的菜品，建议推出限时折扣活动',
                        confidence: '85%'
                    },
                    {
                        icon: '🎯',
                        title: '套餐组合优化',
                        description: '将宫保鸡丁和蛋炒饭组合，提高客单价',
                        confidence: '88%'
                    }
                ]);
            }, 2500);
        }
        
        function predictDemand() {
            showLoading();
            
            setTimeout(() => {
                hideLoading();
                showAnalysis([
                    { value: '156', label: '预计明日订单量' },
                    { value: '35%', label: '宫保鸡丁需求占比' },
                    { value: '28%', label: '麻婆豆腐需求占比' },
                    { value: '42分钟', label: '平均配送时间' }
                ]);
                
                showRecommendations([
                    {
                        icon: '📊',
                        title: '库存准备建议',
                        description: '建议提前准备宫保鸡丁食材，预计需求增长30%',
                        confidence: '90%'
                    },
                    {
                        icon: '⏰',
                        title: '营业时间优化',
                        description: '建议延长午餐时间至14:00，抓住更多订单机会',
                        confidence: '87%'
                    },
                    {
                        icon: '🏍️',
                        title: '骑手调度建议',
                        description: '12:00-13:00时段需要增加2名骑手',
                        confidence: '83%'
                    }
                ]);
            }, 3000);
        }
        
        function optimizeRoutes() {
            showLoading();
            
            setTimeout(() => {
                hideLoading();
                showAnalysis([
                    { value: '-15%', label: '配送时间减少' },
                    { value: '8.5km', label: '平均配送距离' },
                    { value: '3.2单', label: '每趟配送单数' },
                    { value: '92%', label: '准时送达率' }
                ]);
                
                showRecommendations([
                    {
                        icon: '🗺️',
                        title: '最优路线规划',
                        description: '为张师傅规划了包含3个订单的最优配送路线，预计节省12分钟',
                        confidence: '95%'
                    },
                    {
                        icon: '⚡',
                        title: '实时路况优化',
                        description: '避开当前拥堵路段，选择更快的替代路线',
                        confidence: '88%'
                    },
                    {
                        icon: '🎯',
                        title: '订单聚类建议',
                        description: '将相邻区域的订单分配给同一骑手，提高配送效率',
                        confidence: '91%'
                    }
                ]);
            }, 2200);
        }
        
        function showAnalysis(data) {
            const analysisGrid = document.getElementById('analysisGrid');
            analysisGrid.innerHTML = data.map(item => `
                <div class="analysis-item">
                    <div class="analysis-value">${item.value}</div>
                    <div class="analysis-label">${item.label}</div>
                </div>
            `).join('');
            
            document.getElementById('aiAnalysis').style.display = 'block';
        }
        
        function showRecommendations(recommendations) {
            const recommendationsDiv = document.getElementById('recommendations');
            recommendationsDiv.innerHTML = recommendations.map(rec => `
                <div class="recommendation-item">
                    <div class="recommendation-icon">${rec.icon}</div>
                    <div class="recommendation-content">
                        <div class="recommendation-title">${rec.title}</div>
                        <div class="recommendation-description">${rec.description}</div>
                    </div>
                    <div class="confidence-score">${rec.confidence}</div>
                </div>
            `).join('');
            
            document.getElementById('recommendationList').style.display = 'block';
        }
        
        // 页面加载时的初始化
        window.onload = function() {
            // 可以在这里添加一些初始化逻辑
            console.log('AI推荐系统已加载');
        };
    </script>
</body>
</html>
